//
//  LKDailyChartTeamViewController.m
//  YLHelper
//
//  Created by she1323 on 2018/8/8.
//  Copyright © 2018年 she1323. All rights reserved.
//


#import "LKDailyChartTeamViewController.h"
#import "LKDailyChartHeaderTeamCell.h"
#import "LKDailyChartBottomCell.h"
#import "LKLineView.h"
#import "LKDailyTeamRankViewController.h"
#import "LKDailyChartTeamChooseViewController.h"
#import "LKDailyChartModel.h"
#import "LKDoubuleBarView.h"
#import "LKChartShowRuleCell.h"
@interface LKDailyChartTeamViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)LKBaseTableview *tableview;
@property(nonatomic,strong)UISegmentedControl *chartsSegment;
@property(nonatomic,strong)UILabel *YLabelTitle;
@property(nonatomic,strong)NSArray *YtitlesArray;
@property(nonatomic,assign)NSInteger selectType;
@property(nonatomic,strong)UISegmentedControl *headerSeg;
@property(nonatomic,assign)NSInteger headerSelect;
@property(nonatomic,strong)NSMutableArray *linedataArray;
@property(nonatomic,strong)NSMutableArray *dateArray;
@property(nonatomic,copy)NSString *dayCustomerAdd;
@property(nonatomic,strong)LKDailyChartModel *chartModel;

@end

@implementation LKDailyChartTeamViewController

-(LKBaseTableview *)tableview{
    if (!_tableview) {
        _tableview = [LKBaseTableview setTableviewWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT) style:UITableViewStylePlain registercellClasss:@[@"LKDailyChartHeaderTeamCell",@"LKDailyChartBottomCell",@"LKChartShowRuleCell"]];
        [self.view addSubview:_tableview];
        _tableview.delegate = self;
        _tableview.dataSource = self;
        _tableview.separatorStyle = UITableViewCellSelectionStyleGray;
        _tableview.tableFooterView = [[UIView alloc] init];
        _tableview.backgroundColor = cellHeaderBgColor;
    }
    return _tableview;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    if (self.departmentId) {
        
    }else{
        self.departmentId = @"0";
    }
    if (self.departmentName) {
        
    }else{
        self.departmentName = @"团队";
    }
    
    self.chartModel = [[LKDailyChartModel alloc] init];
    self.dateArray = [[NSMutableArray alloc] init];
    [self.dateArray addObjectsFromArray:@[@"0",@"0",@"0",@"0",@"0",@"0",@"0"]];
    self.tableview.estimatedRowHeight = 200;
    self.tableview.estimatedSectionFooterHeight = 200;
    self.selectType = 0;
    self.headerSelect = 0;
    [self.tableview reloadData];
    [self getAllDdataAndShowWithType:self.headerSelect];
    [self getLinedatasArray:self.selectType];
    LKDailyChartHeaderTeamCell *cell = [self.tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
    [self getRankSortPositionButtonType:cell.topBtn];
    
    // Do any additional setup after loading the view.
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:blueDefault}];
    [self.navigationController.navigationBar setBarTintColor:COLOR_HEX(0xffffff)];
}

-(void)setNavgationBackBtn{
    [super setNavgationBackBtn];
    [self.backButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.backButton setImage:[UIImage imageNamed:@"back2"] forState:UIControlStateNormal];
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:[UIImage imageNamed:@"04more"] forState:UIControlStateNormal];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
    [btn addTarget:self action:@selector(chooseTeamAction:) forControlEvents:UIControlEventTouchUpInside];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        LKDailyChartHeaderTeamCell *headerCell = [tableView dequeueReusableCellWithIdentifier:@"LKDailyChartHeaderTeamCell"];
        headerCell.type = self.headerSelect;
        [headerCell.segmentControl addTarget:self action:@selector(dayAndMonthSwichAction:) forControlEvents:UIControlEventValueChanged];
        headerCell.segmentControl.selectedSegmentIndex = self.headerSelect;
        [headerCell.rightButton addTarget:self action:@selector(chooseTeamAction:) forControlEvents:UIControlEventTouchUpInside];
        [headerCell.backBtn addTarget:self action:@selector(backback:) forControlEvents:UIControlEventTouchUpInside];
        [headerCell.sortRankBtn addTarget:self action:@selector(gotoseeRank:) forControlEvents:UIControlEventTouchUpInside];
        [headerCell.topBtn addTarget:self action:@selector(topTypeBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        headerCell.btnContent = self.departmentName;
        return headerCell;
    }
    if (indexPath.section == 2) {
        LKChartShowRuleCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LKChartShowRuleCell"];
        return cell;
    }
    LKDailyChartBottomCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LKDailyChartBottomCell"];
    for (UIView * view in cell.contentView.subviews) {
        [view removeFromSuperview];
    }
    UILabel *headerLabel = [[UILabel alloc] init];
    [cell.contentView addSubview:headerLabel];
    headerLabel.text = @"最近七天趋势图";
    headerLabel.textColor = cellTextColor;
    headerLabel.font = [UIFont systemFontOfSize:13];
    [headerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(cell.contentView.mas_left).offset(15);
        make.top.equalTo(cell.contentView.mas_top).offset(5);
    }];
    UIView *lineV = [[UIView alloc] init];
    lineV.backgroundColor = blueDefault;
    [cell.contentView addSubview:lineV];
    [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(headerLabel.mas_left).offset(-3);
        make.top.equalTo(headerLabel.mas_top);
        make.bottom.equalTo(headerLabel.mas_bottom);
        make.width.mas_equalTo(3);
    }];
    
    self.YLabelTitle = [[UILabel alloc] init];
    [cell.contentView addSubview:self.YLabelTitle];
    self.YLabelTitle.text = self.YtitlesArray[self.selectType];
    self.YLabelTitle.textColor = cellTextColor;
    self.YLabelTitle.font = [UIFont systemFontOfSize:10];
    [self.YLabelTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(cell.contentView.mas_left).offset(15);
        make.top.equalTo(headerLabel.mas_bottom).offset(10);
    }];
    LKLineView *lineView = [LKLineView createLineViewWithFrame:CGRectMake(13, 0, WIDTH - 26, 320)  AndLineValues:@[self.linedataArray] AndXValue:self.dateArray AndShowShowRightAxis:NO AndLinesClors:@[blueDefault] AndLineNames:@[@""] AndDrawFillCorlor:@[[UIColor clearColor]]];
    
    
    
    [cell.contentView addSubview:lineView];
    return cell;
}

/**
 选择team查看详情信息

 */
-(void)chooseTeamAction:(UIButton *)btn{
    LKDailyChartTeamChooseViewController *vc = [[LKDailyChartTeamChooseViewController alloc] init];
    vc.departmentId = self.departmentId;
    [self.navigationController pushViewController:vc animated:YES];
}

/**
 年化业绩和规模业绩的按钮切换事件
 
 @param btn 切换按钮
 */
-(void)topTypeBtnAction:(UIButton *)btn{
    btn.selected = !btn.selected;
    LKDailyChartHeaderTeamCell *cell = [self.tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
    if (self.headerSelect == 0) {
        if (btn.selected) {
            cell.moneyLabel.text = self.chartModel.dayNianhuaMoney;
        }else{
            cell.moneyLabel.text = self.chartModel.dayMoney;
        }
    }else{
        if (btn.selected) {
            cell.moneyLabel.text = self.chartModel.monthNianhuaMoney;
        }else{
            cell.moneyLabel.text = self.chartModel.monthMoney;
        }
    }
    [self getRankSortPositionButtonType:btn];
    
}

/**
 自定义的头部返回按钮

 @param btn 自定义按钮
 */
-(void)backback:(UIButton *)btn{
    [self back];
}

/**
 查看排名
 
 @param btn 排名按钮
 */
-(void)gotoseeRank:(UIButton *)btn{
    LKDailyChartHeaderTeamCell *cell = [self.tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
    NSString *url;
    if (cell.topBtn.selected) {
        url = teamThirtyNianhuayejiListUrl;
    }else{
        url = teamThirtyGuimoyejiListUrl;
    }
    LKDailyTeamRankViewController *vc = [[LKDailyTeamRankViewController alloc] init];
    vc.url = url;
    vc.type = self.headerSelect;
    vc.departmenId = self.departmentId;
    vc.departmentName = self.departmentName;
    [self.navigationController pushViewController:vc animated:YES];
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return 315 + STATUS_BAR_HEIGHT;
    }else{
        if (indexPath.section == 2) {
            return UITableViewAutomaticDimension;
        }
    }
    return 350;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
     return section == 0 ? 0.0000000000001:30;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return section == 0 ? 12 : 0.0000000000001;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = cellHeaderBgColor;
    if (section == 1) {
        view.backgroundColor = [UIColor whiteColor];
        UIView *btnsView = [[UIView alloc] init];
        btnsView.backgroundColor = [UIColor whiteColor];
        [view addSubview:btnsView];
        [btnsView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(view.mas_left).offset(5);
            make.right.equalTo(view.mas_right).offset(-5);
            make.top.equalTo(view.mas_top);
            make.height.mas_equalTo(30);
        }];
        NSArray *titlesArra = @[@"规模业绩",@"年化业绩",@"新客增长",@"续投率",@"折标率",@"人均产能"];
        NSMutableArray *btnsArra = [[NSMutableArray alloc] init];
        for (NSInteger i = 0; i < titlesArra.count; i++) {
            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
            [btn setTitleColor:cellTextColor forState:UIControlStateNormal];
            [btn setTitleColor:blueDefault forState:UIControlStateSelected];
            btn.titleLabel.font = [UIFont systemFontOfSize:13];
            if (WIDTH <  375) {
                 btn.titleLabel.font = [UIFont systemFontOfSize:10];
            }
            [btn setTitle:titlesArra[i] forState:UIControlStateNormal];
            [btn setTitle:titlesArra[i] forState:UIControlStateSelected];
            btn.tag = 10000 + i;
            [btn addTarget:self action:@selector(diffrentTypeChooseAction:) forControlEvents:UIControlEventTouchUpInside];
            [btnsView addSubview:btn];
            [btnsArra addObject:btn];
        }
        
        [btnsArra mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:5 leadSpacing:0 tailSpacing:0];
        [btnsArra mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(btnsView.mas_top).offset(0);
            make.height.equalTo(@30);
        }];
        for (UIButton *btn in btnsArra) {
            if (btn.tag - 10000 == self.selectType) {
                btn.selected = YES;
                UIView *layer = [[UIView alloc] init];
                layer.backgroundColor = blueDefault;
                layer.frame = CGRectMake(0, 29, (WIDTH - 10 - (titlesArra.count - 1) * 5)/titlesArra.count , 1);
                [btn addSubview:layer];
            }
        }
        
        
    }
    if (section == 2) {
        view.backgroundColor = [UIColor whiteColor];
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.textAlignment = NSTextAlignmentCenter;
        titleLabel.text = @"数据显示规则";
        titleLabel.font = [UIFont systemFontOfSize:15];
        titleLabel.textColor = cellTextColor;
        [view addSubview:titleLabel];
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(view.mas_left).offset(15);
            make.centerX.equalTo(view);
            make.centerY.equalTo(view);
            make.height.mas_equalTo(30);
        }];
        UIView *lineV = [[UIView alloc] init];
        lineV.backgroundColor = cellHeaderBgColor;
        [view addSubview:lineV];
        [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.left.equalTo(view);
            make.bottom.equalTo(view.mas_bottom);
            make.height.mas_equalTo(1);
        }];
    }

    return view;
}

/**
 分段选择器本日和本月之间的数据的切换
 
 @param seg 分段选择器
 */
-(void)dayAndMonthSwichAction:(UISegmentedControl *)seg{
    LKDailyChartHeaderTeamCell *cell = [self.tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
    self.headerSelect = seg.selectedSegmentIndex;
    [self getAllDdataAndShowWithType:seg.selectedSegmentIndex];
    [self getRankSortPositionButtonType:cell.topBtn];
    switch (seg.selectedSegmentIndex) {
        case 0:
        {
            
        }
            break;
        case 1:
        {

        }
            break;
            
        default:
            break;
    }
}

/**
 切换分段选择器的不同按钮的选择事件
 
 @param seg 分段选择器
 */
-(void)diffrentTypeChooseAction:(UIButton *)seg{
    [self.linedataArray removeAllObjects];
    self.selectType = seg.tag - 10000;
    [self getLinedatasArray:self.selectType];

}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    if (scrollView.contentOffset.y > 64) {
        scrollView.contentInset = UIEdgeInsetsMake(NAVIGATION_BAR_HEIGHT, 0, 0, 0);
        [self.navigationController setNavigationBarHidden:NO animated:YES];
        [self.navigationController.navigationBar setBarTintColor:blueDefault];
        //设置导航条文字颜色 白色
        [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    }
    if (scrollView.contentOffset.y < 64) {
        scrollView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
        [self.navigationController setNavigationBarHidden:YES animated:YES];
    }
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = [UIColor whiteColor];
    return view;
}

/**
 数据的获取并展示
 */
/**
 数据的获取并展示
 */
-(void)getAllDdataAndShowWithType:(NSInteger)type{
    NSDictionary *param = @{@"DepartmentId":self.departmentId};
    LKDailyChartHeaderTeamCell *cell = [self.tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
    cell.customersLabel.text = @"***";
    cell.xutoulvLabel.text = @"***";
    cell.zhebiaolvLabel.text = @"***";
    MBProgressHUD * customerHud = [MBProgressHUD showHUDAddedTo:cell.cutomersView animated:YES];
    [self setHudStyle:customerHud];
    MBProgressHUD * zhebiaoHud = [MBProgressHUD showHUDAddedTo:cell.zhebiaoView animated:YES];
    [self setHudStyle:zhebiaoHud];
    MBProgressHUD * xutouHud = [MBProgressHUD showHUDAddedTo:cell.xutouView animated:YES];
    [self setHudStyle:xutouHud];
    MBProgressHUD * moneyHud = [MBProgressHUD showHUDAddedTo:cell.moneyLabel animated:YES];
    [self setHudStyle:moneyHud];
    MBProgressHUD *renjunHud = [MBProgressHUD showHUDAddedTo:cell.renjunenergyView animated:YES];
    [self setHudStyle:renjunHud];
    if (type == 0) {
        //日的数据效果
        //续投率
        if (self.chartModel.dayXutoulv) {
            [xutouHud hideAnimated:YES];
            cell.xutoulvLabel.text = self.chartModel.dayXutoulv;
        }else{
            [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:teamDayXutoulvUrl header:[LKUserInforTool header] parameters:param progress:^(NSProgress * _Nullable progress) {
                
            } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                [xutouHud hideAnimated:YES];
                self.chartModel.dayXutoulv = responseObject[@"result"][@"markingRateText"];
                cell.xutoulvLabel.text = self.chartModel.dayXutoulv;
            } failure:^(NSString * _Nullable errorMessage) {
                
            }];
        }
        //新客增长
        if (self.chartModel.dayCutomersNumber) {
            [customerHud hideAnimated:YES];
            cell.customersLabel.text = self.chartModel.dayCutomersNumber;
        }else{
            [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:teamDayCustomerUrl header:[LKUserInforTool header] parameters:param progress:^(NSProgress * _Nullable progress) {
                
            } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                [customerHud hideAnimated:YES];
                self.chartModel.dayCutomersNumber = [NSString stringWithFormat:@"%@",responseObject[@"result"][@"customerGrowthNum"]];
                cell.customersLabel.text = self.chartModel.dayCutomersNumber;
            } failure:^(NSString * _Nullable errorMessage) {
                
            }];
        }
        //日的规模业绩，年化业绩，折标率
        if (self.chartModel.dayZhebiaolv) {
            [moneyHud hideAnimated:YES];
            [zhebiaoHud hideAnimated:YES];
            cell.zhebiaolvLabel.text = self.chartModel.dayZhebiaolv;
            if (cell.topBtn.selected) {
                cell.moneyLabel.text = self.chartModel.dayNianhuaMoney;
            }else{
                cell.moneyLabel.text = self.chartModel.dayMoney;
            }
            cell.caculateDateLabel.text = [NSString stringWithFormat:@"数据统计截止至 %@",[NSString getCurrentTime]];
        }else{
            [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:teamDayOtherDailyChartUrl header:[LKUserInforTool header] parameters:param progress:^(NSProgress * _Nullable progress) {
                
            } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                [moneyHud hideAnimated:YES];
                [zhebiaoHud hideAnimated:YES];
                self.chartModel.dayMoney = responseObject[@"result"][@"investmentAmountSumTest"];
                self.chartModel.dayNianhuaMoney = responseObject[@"result"][@"interestRateTest"];
                self.chartModel.dayZhebiaolv = responseObject[@"result"][@"markinRrate"];
                self.chartModel.caculateDate = responseObject[@"result"][@"calulationDateTest"];
                if (cell.topBtn.selected) {
                    cell.moneyLabel.text = self.chartModel.dayNianhuaMoney;
                }else{
                    cell.moneyLabel.text = self.chartModel.dayMoney;
                }
                cell.zhebiaolvLabel.text = self.chartModel.dayZhebiaolv;
                cell.caculateDateLabel.text = [NSString stringWithFormat:@"数据统计截止至 %@",[NSString getCurrentTime]];
            } failure:^(NSString * _Nullable errorMessage) {
                
            }];
        }
        
        //日的团队人均产能
        if (self.chartModel.dayrenjunEmergy) {
            [renjunHud hideAnimated:YES];
            cell.renjunchanLabel.text = self.chartModel.dayrenjunEmergy;
        }else{
            [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:teamDayRenjunEmergyUrl header:[LKUserInforTool header] parameters:param progress:^(NSProgress * _Nullable progress) {
                
            } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                [renjunHud hideAnimated:YES];
                self.chartModel.dayrenjunEmergy = responseObject[@"result"][@"amountAverage"];
                cell.renjunchanLabel.text = self.chartModel.dayrenjunEmergy;
                
            } failure:^(NSString * _Nullable errorMessage) {
                
            }];
        }
        
    }else{
        //月的数据效果
        //续投率
        if (self.chartModel.monthXutoulv) {
            [xutouHud hideAnimated:YES];
            cell.xutoulvLabel.text = self.chartModel.monthXutoulv;
        }else{
            [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:teamMonthXutoulvUrl header:[LKUserInforTool header] parameters:param progress:^(NSProgress * _Nullable progress) {
                
            } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                [xutouHud hideAnimated:YES];
                self.chartModel.monthXutoulv = responseObject[@"result"][@"markingRateText"];
                cell.xutoulvLabel.text = self.chartModel.monthXutoulv;
            } failure:^(NSString * _Nullable errorMessage) {
                
            }];
        }
        //新客增长
        if (self.chartModel.monthCutomersNumber) {
            [customerHud hideAnimated:YES];
            cell.customersLabel.text = self.chartModel.monthCutomersNumber;
        }else{
            [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:teamMonthCusotmerUrl header:[LKUserInforTool header] parameters:param progress:^(NSProgress * _Nullable progress) {
                
            } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                [customerHud hideAnimated:YES];
                self.chartModel.monthCutomersNumber = [NSString stringWithFormat:@"%@",responseObject[@"result"][@"customerGrowthNum"]];
                cell.customersLabel.text = self.chartModel.monthCutomersNumber;
            } failure:^(NSString * _Nullable errorMessage) {
                
            }];
        }
        //规模业绩，年化业绩，折标率
        if (self.chartModel.monthZhebiaolv) {
            [moneyHud hideAnimated:YES];
            [zhebiaoHud hideAnimated:YES];
            if (cell.topBtn.selected) {
                cell.moneyLabel.text = self.chartModel.monthNianhuaMoney;
            }else{
                cell.moneyLabel.text = self.chartModel.monthMoney;
            }
            cell.zhebiaolvLabel.text = self.chartModel.monthZhebiaolv;
            cell.caculateDateLabel.text = [NSString stringWithFormat:@"数据统计截止至 %@",[NSString getCurrentTime]];
        }else{
            [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:teamMonthOtherDailyChartUrl header:[LKUserInforTool header] parameters:param progress:^(NSProgress * _Nullable progress) {
                
            } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                [moneyHud hideAnimated:YES];
                [zhebiaoHud hideAnimated:YES];
                self.chartModel.monthMoney = responseObject[@"result"][@"investmentAmountSumTest"];
                self.chartModel.monthZhebiaolv = responseObject[@"result"][@"markinRrate"];
                self.chartModel.caculateDate = responseObject[@"result"][@"calulationDateTest"];
                self.chartModel.monthNianhuaMoney = responseObject[@"result"][@"interestRateTest"];
                if (cell.topBtn.selected) {
                    cell.moneyLabel.text = self.chartModel.monthNianhuaMoney;
                }else{
                    cell.moneyLabel.text = self.chartModel.monthMoney;
                }
                cell.zhebiaolvLabel.text = self.chartModel.monthZhebiaolv;
                cell.caculateDateLabel.text = [NSString stringWithFormat:@"数据统计截止至 %@",[NSString getCurrentTime]];
            } failure:^(NSString * _Nullable errorMessage) {
                
            }];
        }
        //日的团队人均产能
        if (self.chartModel.monthrenjundayrenjunEmergy) {
            [renjunHud hideAnimated:YES];
            cell.renjunchanLabel.text = self.chartModel.monthrenjundayrenjunEmergy;
        }else{
            [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:teamMonthRenjunEmergyUrl header:[LKUserInforTool header] parameters:param progress:^(NSProgress * _Nullable progress) {
                
            } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                [renjunHud hideAnimated:YES];
                self.chartModel.monthrenjundayrenjunEmergy = responseObject[@"result"][@"amountAverage"];
                cell.renjunchanLabel.text = self.chartModel.monthrenjundayrenjunEmergy;
                
            } failure:^(NSString * _Nullable errorMessage) {
                
            }];
        }
        
    }
    
}
/**
 获取过去七天各个类型的折线数据
 
 @param type 类型
 */
-(void)getLinedatasArray:(NSInteger)type{
//    [self.linedataArray removeAllObjects];
//    [self.dateArray removeAllObjects];
    NSString *selectUrl;
    NSDictionary *param = @{@"DepartmentId":self.departmentId};
    switch (type) {
        case 0:
        {
            selectUrl = teamSevendayOtherDailyChartUrl;
            [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:selectUrl header:[LKUserInforTool header] parameters :param progress:^(NSProgress * _Nullable progress) {
                
            } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                [self.linedataArray removeAllObjects];
                [self.dateArray removeAllObjects];
                NSArray *valuesArray = responseObject[@"result"];
                for (NSDictionary *valueDic in valuesArray) {
                    if ([valueDic[@"investmentAmountSumTest"] isEqual:@"--"]) {
                        [self.linedataArray addObject:@"0.00"];
                    }else{
                        [self.linedataArray addObject:valueDic[@"investmentAmountSumTest"]];
                    }
                    [self.dateArray addObject:valueDic[@"calulationDateTest"]];
                }
                [self.tableview reloadSection:1 withRowAnimation:UITableViewRowAnimationNone];
            } failure:^(NSString * _Nullable errorMessage) {
                
            }];
        }
            break;
        case 1:
        {
            selectUrl = teamSevendayOtherDailyChartUrl;
            [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:selectUrl header:[LKUserInforTool header] parameters:param progress:^(NSProgress * _Nullable progress) {
                
            } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                [self.linedataArray removeAllObjects];
                [self.dateArray removeAllObjects];
                NSArray *valuesArray = responseObject[@"result"];
                for (NSDictionary *valueDic in valuesArray) {
                    if ([valueDic[@"interestRateTest"] isEqual:@"--"]) {
                        [self.linedataArray addObject:@"0.00"];
                    }else{
                        [self.linedataArray addObject:valueDic[@"interestRateTest"]];
                    }
                    [self.dateArray addObject:valueDic[@"calulationDateTest"]];
                }
                
                [self.tableview reloadSection:1 withRowAnimation:UITableViewRowAnimationNone];
            } failure:^(NSString * _Nullable errorMessage) {
                
            }];
        }
            break;
        case 2:
        {
            selectUrl = teamSevenDayCustomerUrl;
            [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:selectUrl header:[LKUserInforTool header] parameters:param progress:^(NSProgress * _Nullable progress) {
                
            } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                [self.linedataArray removeAllObjects];
                [self.dateArray removeAllObjects];
                NSArray *valuesArray = responseObject[@"result"];
                for (NSDictionary *valueDic in valuesArray) {
                    if ([valueDic[@"customerGrowthNum"] isEqual:@"--"]) {
                        [self.linedataArray addObject:@"0"];
                    }else{
                        [self.linedataArray addObject:valueDic[@"customerGrowthNum"]];
                    }
                    [self.dateArray addObject:valueDic[@"customerCreateTimeTest"]];
                }
                
                [self.tableview reloadSection:1 withRowAnimation:UITableViewRowAnimationNone];
            } failure:^(NSString * _Nullable errorMessage) {
                
            }];
        }
            break;
        case 3:
        {
            selectUrl = teamSevenDayXutoulvUrl;
            [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:selectUrl header:[LKUserInforTool header] parameters:param progress:^(NSProgress * _Nullable progress) {
                
            } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                [self.linedataArray removeAllObjects];
                [self.dateArray removeAllObjects];
                NSArray *valuesArray = responseObject[@"result"];
                for (NSDictionary *valueDic in valuesArray) {
                    if ([valueDic[@"markingRateText"] isEqual:@"--"]) {
                        [self.linedataArray addObject:@"0.00"];
                    }else{
                        [self.linedataArray addObject:valueDic[@"markingRateText"]];
                    }
                    [self.dateArray addObject:valueDic[@"markingTimeTest"]];
                }
                
                [self.tableview reloadSection:1 withRowAnimation:UITableViewRowAnimationNone];
            } failure:^(NSString * _Nullable errorMessage) {
                
            }];
        }
            break;
        case 4:
        {
            selectUrl = teamSevendayOtherDailyChartUrl;
            [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:selectUrl header:[LKUserInforTool header] parameters:param progress:^(NSProgress * _Nullable progress) {
                
            } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                [self.linedataArray removeAllObjects];
                [self.dateArray removeAllObjects];
                NSArray *valuesArray = responseObject[@"result"];
                for (NSDictionary *valueDic in valuesArray) {
                    if ([valueDic[@"markinRrate"] isEqual:@"--"]) {
                        [self.linedataArray addObject:@"0.00"];
                    }else{
                        [self.linedataArray addObject:valueDic[@"markinRrate"]];
                    }
                    [self.dateArray addObject:valueDic[@"calulationDateTest"]];
                }
                
                [self.tableview reloadSection:1 withRowAnimation:UITableViewRowAnimationNone];
            } failure:^(NSString * _Nullable errorMessage) {
                
            }];
        }
            break;
        case 5:
        {
            selectUrl = teamSevenDayRenjunEmergyUrl;
            [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:selectUrl header:[LKUserInforTool header] parameters:param progress:^(NSProgress * _Nullable progress) {
                
            } success:^(BOOL isSuccess, id  _Nullable responseObject) {
                [self.linedataArray removeAllObjects];
                [self.dateArray removeAllObjects];
                NSArray *valuesArray = responseObject[@"result"];
                for (NSDictionary *valueDic in valuesArray) {
                    if ([valueDic[@"amountAverage"] isEqual:@"--"]) {
                        [self.linedataArray addObject:@"0.00"];
                    }else{
                        [self.linedataArray addObject:valueDic[@"amountAverage"]];
                    }
                    [self.dateArray addObject:valueDic[@"reportTimeTest"]];
                }
                
                [self.tableview reloadSection:1 withRowAnimation:UITableViewRowAnimationNone];
            } failure:^(NSString * _Nullable errorMessage) {
                
            }];
        }
            break;
        default:
            break;
    }
    
}


/**
 设置hud的样式

 @param hud 相对应的父视图
 */
-(void)setHudStyle:(MBProgressHUD *)hud{
    hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
    hud.bezelView.color = [[UIColor whiteColor] colorWithAlphaComponent:0.0];
    [UIActivityIndicatorView appearanceWhenContainedInInstancesOfClasses:@[[hud class]]].color = [UIColor whiteColor];
    hud.mode = MBProgressHUDModeIndeterminate;
}

/**
 获取所选类型的排名情况
 
 @param btn 年化业绩还是规模业绩的排名
 */
-(void)getRankSortPositionButtonType:(UIButton *)btn{
    LKDailyChartHeaderTeamCell *cell = [self.tableview cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
    NSDictionary *param = @{@"DepartmentId":self.departmentId};
    NSString *url;
    if (self.headerSelect) {
        url = teamMonthRankPositionUrl;
    }else{
        url = teamDayRankPositionUrl;
    }
    [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:url header:[LKUserInforTool header] parameters:param progress:^(NSProgress * _Nullable progress) {
        
    } success:^(BOOL isSuccess, id  _Nullable responseObject) {
        NSDictionary *dic = responseObject[@"result"];
        if (btn.selected) {
            [cell.sortRankBtn setTitle:[NSString stringWithFormat:@"当前排名%@",dic[@"interestRateRanking"]] forState:UIControlStateNormal];
        }else{
            [cell.sortRankBtn setTitle:[NSString stringWithFormat:@"当前排名%@",dic[@"investmentAmountSumRanking"]] forState:UIControlStateNormal];
        }
    } failure:^(NSString * _Nullable errorMessage) {
        
    }];
}

-(NSArray *)YtitlesArray{
    if (!_YtitlesArray) {
        _YtitlesArray = @[@"金额(万元)",@"金额(万元)",@"人数",@"比率(%)",@"比率(%)",@"金额(万元)"];
    }
    return _YtitlesArray;
}

-(NSMutableArray *)linedataArray{
    if (!_linedataArray) {
        _linedataArray = [[NSMutableArray alloc] initWithArray:@[@"0",@"0",@"0",@"0",@"0",@"0",@"0"]];
    }
    return _linedataArray;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
